public class Solution746 {
    public int minCostClimbingStairs(int[] cost) {
        int[] f=new int[cost.length+1];
        f[0]=f[1]=0;
        for (int i=2;i<=cost.length;i++){
            f[i]=Math.min(f[i-1]+cost[i-1],f[i-2]+cost[i-2]);
        }
        return f[cost.length];
    }

    public static void main(String[] args) {
        System.out.println(new Solution746().minCostClimbingStairs(new int[]{10,15,20}));
    }
}
